<?php

/**
 * Wave Framework <http://www.waveframework.com>
 * View Controller
 *
 * Wave Framework comes with a View Controller and a translations system that is used to build 
 * a website on Wave Framework. This View Controller is entirely optional and can be removed 
 * from a system if you plan to implement your own View Controller or simply use Wave Framework 
 * for API, without a website.
 *
 * @package    Tools
 * @author     Kristo Vaher <kristo@waher.net>
 * @copyright  Copyright (c) 2012, Kristo Vaher
 * @license    GNU Lesser General Public License Version 3
 * @tutorial   /doc/pages/guide_view.htm
 * @since      1.0.0o
 * @version    3.6.9
 */

class WWW_controller_events extends WWW_Factory {

	/**
	 * This method is called by Data Handler to render View contents based on values from 
	 * URL Controller.
	 *
	 * @param array $input input data sent to controller
	 * @input mixed input data from URL Controller output
	 * @return null
	 */
	
	public function create_event_type($data)
	{
		$reason=array();
		if($data['event_type_name']=='')
		{
			$reason['event_typeerror']="Event Type Name should contain some value";
			$status="fail";
		}
		if($data['category_name']=='')
		{
			$reason['category_nameerror']="Category Name should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model=$this->getModel('events');
		$result=$model->create_event_type($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_event_type($data)
	{	
		$reason = array();
		if($data['event_type_name']=='')
		{
			$reason['event_typeerror'] = "Event Type Name should contain some value";
			$status="fail";
		}
		if($data['category_name']=='')
		{
			$reason['category_nameerror']="Category Name should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{	
		$model=$this->getModel('events');
		$result=$model->edit_event_type($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}		
	}
	public function get_event_type($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_type($data);
		
		return $this->resultTrue('result',$result);
	}
	public function delete_event_type($data)
	{	
		$model=$this->getModel('events');
		$result=$model->delete_event_type($data);
		
		return $this->resultTrue('result',$result);
	}
	public function all_event_types($data)
	{	
		$model=$this->getModel('events');
		$result=$model->all_event_types($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_event_type_list($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_type_list($data);
		
		return $this->resultTrue('result',$result);
	}
	public function create_event_location($data)
	{
		$reason=array();
		if($data['location_name']=='')
		{
			$reason['location_nameerror']="Event Location Name should contain some value";
			$status="fail";
		}
		if($data['location_address']=='')
		{
			$reason['location_addresserror']="Address should contain some value";
			$status="fail";
		}
		if($data['location_city']=='')
		{
			$reason['location_cityerror'] = "City Name should contain some value";
			$status="fail";
		}
		if($data['event_type_id']=='')
		{
			$reason['event_type_iderror']="Event Type should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model=$this->getModel('events');
		$result=$model->create_event_location($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_event_location($data)
	{	
		$reason = array();
		if($data['location_name']=='')
		{
			$reason['location_nameerror']="Event Location Name should contain some value";
			$status="fail";
		}
		if($data['location_address']=='')
		{
			$reason['location_addresserror']="Address should contain some value";
			$status="fail";
		}
		if($data['location_city']=='')
		{
			$reason['location_cityerror'] = "City Name should contain some value";
			$status="fail";
		}
		if($data['event_type_id']=='')
		{
			$reason['event_type_iderror']="Event Type should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{	
		$model=$this->getModel('events');
		$result=$model->edit_event_location($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}		
	}
	public function get_event_location($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_location($data);
		
		return $this->resultTrue('result',$result);
	}
	public function delete_event_location($data)
	{	
		$model=$this->getModel('events');
		$result=$model->delete_event_location($data);
		
		return $this->resultTrue('result',$result);
	}
	public function all_event_location($data)
	{	
		$model=$this->getModel('events');
		$result=$model->all_event_location($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_event_location_list($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_location_list($data);
		
		return $this->resultTrue('result',$result);
	}
	public function create_event_price($data)
	{
		$reason=array();
		if($data['pricing_name']=='')
		{
			$reason['pricing_nameerror']="pricing Name should contain some value";
			$status="fail";
		}
		if($data['start_date']=='')
		{
			$reason['start_dateerror']="start date should contain some value";
			$status="fail";
		}
		if($data['pricing_for']=='')
		{
			$reason['pricing_forerror'] = "pricing for should contain some value";
			$status="fail";
		}
		if($data['event_type_id']=='')
		{
			$reason['event_type_iderror']="Event Type should contain some value";
			$status="fail";
		}
		if($data['rate']=='')
		{
			$reason['rateerror']="rate should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model=$this->getModel('events');
		$result=$model->create_event_price($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_event_price($data)
	{	
		$reason=array();
		if($data['pricing_name']=='')
		{
			$reason['pricing_nameerror']="pricing Name should contain some value";
			$status="fail";
		}
		if($data['start_date']=='')
		{
			$reason['start_dateerror']="start date should contain some value";
			$status="fail";
		}
		if($data['pricing_for']=='')
		{
			$reason['pricing_forerror'] = "pricing for should contain some value";
			$status="fail";
		}
		if($data['event_type_id']=='')
		{
			$reason['event_type_iderror']="Event Type should contain some value";
			$status="fail";
		}
		if($data['rate']=='')
		{
			$reason['rateerror']="rate should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{	
		$model=$this->getModel('events');
		$result=$model->edit_event_price($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}		
	}
	public function get_event_price($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_price($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_event_pricing($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_pricing($data);
		
		return $this->resultTrue('result',$result);
	}
	public function delete_event_price($data)
	{	
		$model=$this->getModel('events');
		$result=$model->delete_event_price($data);
		
		return $this->resultTrue('result',$result);
	}
	public function all_event_price($data)
	{	
		$model=$this->getModel('events');
		$result=$model->all_event_price($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_event_price_list($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_price_list($data);
		
		return $this->resultTrue('result',$result);
	}
	public function create_event_offer($data)
	{	
		$reason=array();
		if($data['offer_code']=='')
		{
			$reason['offer_codeerror']="offer code should contain some value";
			$status="fail";
		}
		if($data['start_date']=='')
		{
			$reason['start_dateerror']="start date should contain some value";
			$status="fail";
		}
		if($data['end_date']=='')
		{
			$reason['end_dateerror'] = "end date should contain some value";
			$status="fail";
		}
		if($data['description']=='')
		{
			$reason['descriptionerror']="description should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model = $this->getModel('events');
		//print_r($data);exit;
		$result=$model->create_event_offer($data);
		
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_event_offer($data)
	{	
		$reason=array();
		if($data['offer_code']=='')
		{
			$reason['offer_codeerror']="offer code should contain some value";
			$status="fail";
		}
		if($data['start_date']=='')
		{
			$reason['start_dateerror']="start date should contain some value";
			$status="fail";
		}
		if($data['end_date']=='')
		{
			$reason['end_dateerror'] = "end date should contain some value";
			$status="fail";
		}
		if($data['description']=='')
		{
			$reason['descriptionerror']="description should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{	
		$model=$this->getModel('events');
		$result=$model->edit_event_offer($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}		
	}
	public function get_event_offer($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_event_offer($data);
		
		return $this->resultTrue('result',$result);
	}
	
	public function delete_event_offer($data)
	{	
		$model=$this->getModel('events');
		$result=$model->delete_event_offer($data);
		
		return $this->resultTrue('result',$result);
	}
	public function all_event_offer($data)
	{	
		$model=$this->getModel('events');
		$result=$model->all_event_offer($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_offer_list($data)
	{	
		$model=$this->getModel('events');
		$result=$model->get_offer_list($data);
		
		return $this->resultTrue('result',$result);
	}
	public function create_event($data)
	{	
		$reason=array();
		if($data['director']!="" || $data['producer']!="" || $data['music_director']!="" || $data['release_date']!="" || $data['star_cast']!="")
		{
		if($data['director']=='')
		{
			$reason['directorerror']="Director should contain some value";
			$status="fail";
		}
		if($data['producer']=='')
		{
			$reason['producererror']="Producer should contain some value";
			$status="fail";
		}
		if($data['music_director']=='')
		{
			$reason['music_directorerror'] = "Music Director should contain some value";
			$status="fail";
		}
		if($data['release_date']=='')
		{
			$reason['release_dateerror']="Release Date should contain some value";
			$status="fail";
		}
		if($data['star_cast']=='')
		{
			$reason['star_casterror']="Star Cast should contain some value";
			$status="fail";
		}
		}
		if($data['event_title']=='')
		{
			$reason['event_titleerror']="Event Title should contain some value";
			$status="fail";
		}
		if($data['event_type_id']=='')
		{
			$reason['event_typeerror']="event type should contain some value";
			$status="fail";
		}
		if($data['association_id']=='')
		{
			$reason['associationerror'] = "Association should contain some value";
			$status="fail";
		}
		if($data['credit_card_charges']=='')
		{
			$reason['credit_card_chargeserror']="credit_card_charges should contain some value";
			$status="fail";
		}
		if($data['location_id']=='')
		{
			$reason['location_error']="Location should contain some value";
			$status="fail";
		}
		if($data['event_date']=='')
		{
			$reason['event_dateerror']="Event Date should contain some value";
			$status="fail";
		}
		if($data['event_time']=='')
		{
			$reason['event_timeerror'] = "Event Time should contain some value";
			$status="fail";
		}
		if($data['number_of_tickets']=='')
		{
			$reason['number_of_ticketserror']="Number of tickets should contain some value";
			$status="fail";
		}
		if($data['event_description']=='')
		{
			$reason['descriptionerror']="Description should contain some value";
			$status="fail";
		}
		
		if($status!="fail")
		{
		$model = $this->getModel('events');
		//print_r($data);exit;
		$result=$model->create_event($data);
		
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_event($data)
	{	
		
		$model=$this->getModel('events');
		$result=$model->edit_event($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
			
	}
	public function get_event($data)
	{	
		$model=$this->getModel('events');
		//print_r($data);exit;
		$result=$model->get_event($data);
		
		return $this->resultTrue('result',$result);
	}
	public function delete_event($data)
	{	
		$model=$this->getModel('events');
		//print_r($data);exit;
		$result=$model->delete_event($data);
		
		return $this->resultTrue('result',$result);
	}
	public function all_events($data)
	{	
		$model=$this->getModel('events');
		//print_r($data);exit;
		$result=$model->all_events($data);
		
		return $this->resultTrue('result',$result);
	}
	public function get_association_list()
	{	
		$model=$this->getModel('events');
		//print_r($data);exit;
		$result=$model->get_association_list();
		
		return $this->resultTrue('result',$result);
	}
	
	
}

?>